<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var myMath = {
            max: function() {
                var max = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] > max) {
                        max = arguments[i];
                    }
                }
                return max;
            },
            min: function() {
                var min = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] < min) {
                        min = arguments[i];
                    }
                }
                return min;
            },
        }
        console.log(myMath.max(1, 2, 5, 3, 8));
        console.log(myMath.min(1, 2, 5, 3, 8));
        //绝对值
        console.log(Math.abs(-1));
        console.log(Math.abs("-1")); //隐式转换会把字符串类型的转换为绝对值
        //取整方法
        console.log(Math.floor(2.9)); //向下取整
        console.log(Math.ceil(2.1)); //向上取整
        console.log(Math.round(-2.5)); //四舍五入
        console.log(Math.random() * 8);

        function getrandom(min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        console.log(getrandom(1, 10));
        var arr = ["sd", "asd", "qw"];
        console.log(arr[getrandom(0, arr.length - 1)]);
    </script>
</head>

<body>

</body>

</html>